package com.androidmvp.dreammvp.simple2;
import com.androidmvp.local.table.WeatherInfo;

import java.util.List;

import javax.inject.Inject;

/**
 * Presenter 主要起连接 View 和 Dao 的作用
 */
public class MainPresenter_2 {

    private MainView_2 mainView;
    public WeatherDao_2 weatherDao =new WeatherDao_2(this);

    @Inject
    public MainPresenter_2(MainView_2 mainView) {
        this.mainView=mainView;

    }
    public void getData(){
        mainView.showProgressBar();
        weatherDao.getData();
    }

    public void attachView(MainView_2 loginView){
        this.mainView = loginView;
    }

    public void detachView(){
        this.mainView = null;
    }

    public void loadDataSuccess(List<WeatherInfo> list) {
        mainView.showData(list.get(0));
    }
    public void loadDataFailure(){
        mainView.showData(null);
    }
}
